import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "home",
      component: () => import("../views/homeView.vue"),
      children: [
        // 搜索
        {
          path: "/search",
          name: "search",
          component: () => import("@/views/search/search.vue"),
        },
        //会员购买页面
        {
          path: "/memberPayment",
          name: "memberPayment",
          component: () => import("@/views/memberPayment/memberPayment.vue"),
        },

        // 市场洞察
        // 产品分析
        {
          path: "/productanalysis",
          name: "productanalysis",
          component: () => import("@/views/market/productanalysis.vue"),
        },
        // 医疗行业
        {
          path: "/medical",
          name: "medical",
          component: () => import("@/views/medical/medical.vue"),
        },

        // 数据服务
        {
          path: "/dataservice",
          name: "dataservice",
          component: () => import("@/views/dataService/dataservice.vue"),
          meta: {
            title: "数据导出平台",
          },
        },

        {
          path: "/register",
          name: "register",
          component: () => import("@/views/dataService/register.vue"),
          meta: {
            title: "数据开放平台",
          },
        },

        // 搜索详情
        {
          path: "/searchInfo/:id",
          name: "searchInfo",
          component: () => import("@/views/search/searchInfo.vue"),
        },
      ],
    },

    // 工作台
    {
      path: "/staging",
      name: "staging",
      component: () => import("@/views/staging/staging.vue"),

      children: [
        // 首页
        {
          path: "/home1",
          name: "home1",
          component: () => import("@/views/staging/home/home.vue"),
          meta: {
            title: "首页",
          },
        },
        //设置
        {
          path: "/stagingSetup",
          name: "stagingSetup",
          component: () => import("@/views/staging/stagingSetup.vue"),
          meta: {
            title: "设置",
          },
          children: [
            //修改密码
            {
              path: "/stagingPassword",
              name: "stagingPassword",
              component: () => import("@/views/staging/stagingPassword.vue"),
              meta: {
                title: "修改密码",
              },
            },
            // 账号信息维护
            {
              path: "/stagingInfo",
              name: "stagingInfo",
              component: () => import("@/views/staging/stagingInfo.vue"),
              meta: {
                title: "账号信息维护",
              },
            },
            // 身份信息维护
            {
              path: "/stagingmaintenance",
              name: "stagingmaintenance",
              component: () => import("@/views/staging/stagingmaintenance.vue"),
              meta: {
                title: "身份信息维护",
              },
            },
          ],
        },
        // 订阅收藏
        {
          path: "/subscribe",
          name: "subscribe",
          component: () =>
            import("@/views/staging/SubscriptionService/subscribe.vue"),
          meta: {
            title: "订阅与收藏",
          },
        },
        // 服务
        {
          path: "/service",
          name: "service",
          component: () => import("@/views/staging/service/service.vue"),
          meta: {
            title: "服务",
          },
        },
      ],
    },
  ],
});
// 路由守卫
// router.beforeEach((to, from, next) => {
//   let token = localStorage.getItem("token");
//   if (token) {
//     next();
//     console.log(token);
//   } else {
//     next("/login");
//   }
// });
export default router;
